<template>
  <div class="lesson-detail-score">
    <div class="score-content">
      <p class="desc">
        <template v-if="question.status === 0">
          <el-button
                  v-if="question.userId !== userId"
                  class="question-button"
                  @click="answerQuestion()">我要回答
          </el-button>
          <el-button
                  disabled
                  v-if="question.userId === userId"
                  class="question-button">等待回复中
          </el-button>
        </template>

        <el-button
                disabled
                v-if="question.status === 1"
                class="question-button">已采纳最佳答案
        </el-button>
      </p>
      <div class="bottom">
        <dl>
          <dt>点击数</dt>
          <dd>{{ question.click }}</dd>
        </dl>
        <dl>
          <dt>回答数</dt>
          <dd>{{ question.reply }}</dd>
        </dl>
      </div>
    </div>

  </div>
</template>
<script>
import {mapGetters} from 'vuex';

export default {
  props: {
    question: {
      type: Object
    }
  },
  methods:{
    answerQuestion(){
      // 判断是否登录
      // 无登录
      if (this.userId === ''){
        this.$message.error("请先登录系统！")
        return;
      }
      this.$emit('answer');
    }
  },
  computed: {
    ...mapGetters({
      'userId': 'id'
    })
  },
}
</script>
<style lang="stylus" scoped>
  .lesson-detail-score
    .title
      margin-bottom: 8px;
      font-size: 16px;
      color: #07111b;
      line-height: 24px;
    .score-content
      padding: 24px 4px;
      background-color: #eff2f5;
      border-radius: 8px;
      box-sizing: border-box;
      text-align: center;
      .rate-name
        margin-bottom: 8px;
        font-size: 16px;
        color: #07111b;
        line-height: 24px;
        font-weight: 700;
      .rate
        margin-bottom: 8px;
        color: #fa0;
        font-size: 32px;
        font-weight: 700;
        line-height: 32px;
      .comment-btn
        margin: 0 auto 8px;
        width: 160px;
        height: 36px;
        line-height: 36px;
        text-align: center;
        border-radius: 36px;
        border: 1px solid #f90;
        background-color: #eff2f5;
        font-size: 14px;
        color: #f90;
        cursor: pointer;
        &:hover
          background-color: #f90;
          color: #fff;
      .desc
        margin: 0 auto 16px;
        padding-bottom: 16px;
        width: 90%;
        border-bottom: 1px solid #d9dde1;
        font-size: 12px;
        line-height: 20px;
        color: #93999f;
      .bottom
        display: flex;
        align-items: center;
        dl
          flex: 1;
          font-size: 12px;
          dt
            margin-bottom: 2px;
            color: #07111b;
            line-height: 16px;
          dd
            color: #4d555d;
            line-height: 16px;
  .question-button
    background-color: #1fad4e;
    line-height: 24px;
    color: #fff;
    margin-bottom 10px;
    width 100%
    font-size 16px;
    cursor pointer;
    border-radius: 24px;
</style>
